#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a = 10,b = 20;
    int pid = vfork();
    if(pid < 0){
        perror("fail to vfork");
        return -1;
    }
    //父进程
    else if(pid > 0){
        printf("父进程: a = %d b = %d\n",a,b);
    }
    //子进程
    else{
        a += 5;
        b = b +10;
        printf("子进程: a = %d b = %d\n",a,b);
        exit(0);
    }
    return 0;
}
